<template>
	<view>
		<view class="star">
			<image v-for="(sy,indexy) in starYellow" :key="indexy" class="star-img" src="/static/icon/star-yellow.png"></image>
			<image v-for="(sg,indexg) in starGray" :key="indexg+'y'" class="star-img" src="/static/icon/star-gray.png"></image>
			<view v-if="showscore" class="socre">{{score}}</view>
		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				starYellow: 0,
				starGray: 0,
			};
		},
		props: {
			score: {
				type: Number
			},
			showscore: {
				type: Number,
			}
		},
		created() {
			if (this.score == '' || this.score == 0 || this.score == undefined) {
				this.starYellow = 0;
			}
			this.starYellow = parseInt(this.score / 2);
			this.starGray = 5 - this.starYellow;
		}
	}
</script>

<style>
	.star {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.star-img {
		width: 20upx;
		height: 20upx;
	}

	.socre {
		font-size: 12px;
		color: grey;
		margin-left: 4px;
	}
</style>
